import {createRouter,createWebHashHistory} from "vue-router";
import {ShortLocale} from "~tools/LocaleTool";

const t = ShortLocale("router");
// import opt_flow from "~/pages/opt_flow";

const routes = [
    {
        path:"/person_manage",
        component:()=>import("~/pages/list_demo"),//列表页
        meta:{
            to:["OptDemo","DetailDemo"],    //list_demo跳转到OptDemo，DetailDemo页面的时候缓存list_demo
        }
    },
    {
        path:"/opt_demo",
        component:()=>import("~/pages/opt_demo"),//新建编辑页
        meta:{
            // name:"新建demo"
            renderName({query}){

               if(query.optType == "edit"){
                return t("opt_demo.edit");
               }else{
                return t("opt_demo.create");
               }
            }
        },
    },
    {
        path:"/detail_demo",
        component:()=>import("~/pages/detail_demo"),//详情页
        meta:{
            name:"详情demo"
        },
    },

]


const router = createRouter({
    history:createWebHashHistory(),
    routes
});

// router.afterEach((to,from)=>{
//     //记录上一个访问的路由
//     if(to.path !="/"){
//         sessionStorage.setItem("last_route_path",to.path)
//     }
    
// });


export default router;